function albumGroupMode(data:Object, context:Object):Object
{
	var voData:Object=new Object();

	voData.content=generateGroupList(data, context.slot, context.uri);
	voData.type="doWrapper";
	
	return voData;
}

function generateGroupList(data:Object, slot:String, uri:String):Object
{
	var content:Object=new Object();
	
	var groupListML2:String="";
	for (var i=0; i<data.groups.length; i++)
	{
		groupListML2+=getGroupListItem(data.groups[i]);
	}
	
	var ml2fileStr:String="";
	ml2fileStr+="<moonlight name='"+slot+"' template='"+slot+"-relatedGroupContainer' uri='"+uri+"'>";
	ml2fileStr+=groupListML2;
	ml2fileStr+="</moonlight>";

	content.groups=new Object();	// ml2 template item
	content.groups.type="ml2ti";
	content.groups.template=slot+"-relatedGroupContainer";
	content.groups.data=ml2fileStr;

	// Packages.log("content: "+ml2fileStr, "debug");
	
	return content;
}

function getGroupListItem(groupObj:Object):String
{
	var groupPortlet:String="";
	groupPortlet+="<portlet name='grpItem_"+groupObj.groupId+"' height='20' width='160'>";
	groupPortlet+="<textfield name='grpName_"+groupObj.groupId+"' selectable='no' width='160' height='20' y='-2'>"+groupObj.name+"</textfield>";
	groupPortlet+="<hotspot name='gItem"+groupObj.groupId+"' width='160' height='20' alpha='0' />";
	groupPortlet+="<handler ins='BookSpecial-gItem"+groupObj.groupId+"' type='onRollOver' src='lib:notes.system.events.StateFulButtonEvent.invokeRollOverEvent'/>";
	groupPortlet+="<handler ins='BookSpecial-gItem"+groupObj.groupId+"' type='onRollOut' src='lib:notes.system.events.StateFulButtonEvent.invokeRollOutEvent'/>";
	groupPortlet+="<handler ins='BookSpecial-gItem"+groupObj.groupId+"' type='onPress' src='lib:notes.system.events.StateFulButtonEvent.invokePressEvent'/>";
	groupPortlet+="<handler ins='BookSpecial-gItem"+groupObj.groupId+"' type='onRelease' src='lib:notes.system.events.StateFulButtonEvent.invokeReleaseEvent'/>";
	groupPortlet+="<handler ins='BookSpecial-gItem"+groupObj.groupId+"' type='onReleaseOutside' src='lib:notes.system.events.StateFulButtonEvent.invokeRollOutEvent'/>";
	groupPortlet+="</portlet>";

	return groupPortlet;
}